{% extends 'manage_layout.html' %}

{% block lk %}
    <title>销售管理</title>
{% endblock %}

{% block content %}
    <div class="input-group">
        </div><!-- /input-group -->
    <div class="bs-example" data-example-id="striped-table">
    <table class="table table-striped">
      <thead>
        <tr>
          <th>编号</th>
          <th>名称</th>
          <th>价格</th>
          <th>库存</th>
          <th>销量</th>
          <th>推荐</th>
          <th>操作</th>
        </tr>
      </thead>
      <tbody style="height: 100%">
      {% for goods_item in goods_data %}
        <tr>
          <th scope="row">{{goods_item.id}}</th>
          <td>{{ goods_item.title }}</td>
          <td>{{ goods_item.price }}</td>
          <td>{{ goods_item.inventory}}</td>
          <td>{{ goods_item.sales }}</td>
          <td>{{ goods_item.recommendation }}</td>

          <td>
              <span>
                    <input uid="{{ goods_item.id }}" class="btn btn-danger btn-xs btn-default"  type="button" value="推荐" style="background-color: #4cae4c;border-color: white;">
                    <input uid="{{ goods_item.id }}" class="btn btn-danger btn-xs btn-delete"  type="button" value="取消">
            </span>
          </td>
        </tr>
      {% endfor %}
      </tbody>
    </table>
  </div>
    </div>
    <ul class="pagination">
        {{ page_string }}
     </ul>
 </div>

{% endblock %}
{% block js %}
    <script type="text/javascript">



        $('.btn-delete').click(function (){

           var uid = $(this).attr('uid');
            $.ajax({
                url: "management/delete/recommendation/",
                type: 'GET',
                data: {
                    uid: uid,
                },
                dataType: 'JSON',
                    success: function (res){
                        if(res.status){
                            location.reload();
                        }
                    }

            })

        })

        $('.btn-default').click(function (){

           var uid = $(this).attr('uid');
            $.ajax({
                url: "management/default/recommendation/",
                type: 'GET',
                data: {
                    uid: uid,
                },
                dataType: 'JSON',
                    success: function (res){
                        if(res.status){
                            location.reload();
                        }
                    }

            })

        })

    </script>

{% endblock %}